#include <stdio.h>

int classwise(unsigned char *ip) {
    unsigned char first_byte = ip[0];

    if (first_byte >= 0 && first_byte <= 127) {
        return 0;
    } else if (first_byte >= 128 && first_byte <= 191) {
        return 1;
    } else if (first_byte >= 192 && first_byte <= 223) {
        return 2;
    } else if (first_byte >= 224 && first_byte <= 239) {
        return 3;
    } else if (first_byte >= 240 && first_byte <= 255) {
        return 4;
    } else {
        return -1;
    }
}

int main() {
    unsigned char ip1[] = {10, 0, 0, 1};
    unsigned char ip2[] = {172, 16, 0, 1};
    unsigned char ip3[] = {192, 168, 1, 1};
    unsigned char ip4[] = {224, 0, 0, 1};
    unsigned char ip5[] = {240, 0, 0, 1};

    printf("IP1 Type: %d\n", classwise(ip1));
    printf("IP2 Type: %d\n", classwise(ip2));
    printf("IP3 Type: %d\n", classwise(ip3));
    printf("IP4 Type: %d\n", classwise(ip4));
    printf("IP5 Type: %d\n", classwise(ip5));

    return 0;
}